#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    char Hex[16]={
      '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
    };
    int num=98;
    int result[100]={0};
    int i=0;
    do{
        result[i++] = num%16;
        num /= 16;
    }while(num!=0);
//    int i=100;
    qDebug()<<i;
//    char *hex_num = new char[i]();//初始化没用
    char *hex_num = new char[i+2];

    memset(hex_num,0,i+2);


//    hex_num[i]=0;//数组不要越界了在 [] 中的下标

    for(;i>=0;i--){
        hex_num[i]=Hex[result[i]];
        qDebug("%c",Hex[result[i]]);
    }
    qDebug("%s",hex_num);
    qDebug()<<hex_num;



    delete []hex_num;




    return a.exec();
}
